<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class CmdOutput extends CI_Controller {
	
	function __construct() {
		parent::__construct();
		// used in the view
		$this->load->helper('url');		
	}
	
	public function index()	{
		$preparedCommand = '';
		$environment = '';
		$personalNumber = null;
		$orderId = null;
		$logName = '';
		$debugFileName = '';
		$folderName = '';
		
		echo '<h2>Application Test Automation - Debug file:</h2>';
				
		foreach($_GET as $key => $value) {
				
			// echo '</br> GET: '; 
			// print_r($_GET);
			// echo '</br> key: ';   
			// print_r($key); 
			// echo '</br>'; 
			// echo 'value: ';
			// print_r($value);
			// echo '</br>';	
			
	        if ($key != null) {
	        		
	        	switch ($key) {
					case 'cmd':
						// print_r('</br>key: preparedCommand </br>');
						$preparedCommand = $value;
						print_r('Wprowadzone zmienne: "<b>'.$preparedCommand.'</b>"</br>');
						// print_r('preparedCommand: '.$preparedCommand.' </br>');
			        	break;
					case 'env':	
						// print_r('</br>key: env </br>');
						$environment = $value;
						print_r('Wybrane środowisko testowe: <b>SOS_ST:'.$environment.'</b></br>');
			        	break;
					case 'persNum':	
						// print_r('</br>key: persNum </br>');
						$personalNumber = $value;
						print_r('</br>Wprowadzony pesel: <b>'.$personalNumber.'</b>"</br>');
						// print_r('</br>personalNumber: '.$personalNumber.' </br>');
			        	break;
					case 'ordId':
						// print_r('</br>key: ordId </br>');
						$orderId = $value;
						print_r('Wprowadzone idZamówienia: <b>'.$orderId.'</b></br>');
						// print_r('</br>orderId: '.$orderId.' </br>');
			        	break;
					case 'ln':
						// print_r('</br>key: ordId </br>');
						$logName = $value;
						print_r('Nazwa pliku z logiem: <b>'.$logName.'</b></br>');
						// print_r('</br>logName: '.$logName.' </br>');
			        	break;
					case 'dfn':
						// print_r('</br>key: ordId </br>');
						$debugFileName = $value;
						print_r('Nazwa pliku z wynikami przetwarzania w wierszu polecenia: <b>'.$debugFileName.'</b></br>');
						// print_r('</br>debugFileName: '.$debugFileName.' </br>');
			        	break;
		        	default: 
	        	}
	        	
	        } else {
	        	 // echo '<br/>elseValue: '.$key.'<br/>';
	        }
	    }
	    echo '</br>';
	    // $data;
	    $folderName = substr($logName, 4, 14);
		
	    $data['ln'] = $logName;
	    $data['dfn'] = $debugFileName;		
	    $data['fn'] = $folderName;
		
		$this->load->view('vOutputPage', $data);	
		$this->session->sess_destroy();
	}
}